let Koa = require('koa')
let Router = require('koa-router')
let cors = require('koa-cors')
let fs = require('fs')

const app = new Koa()
const router = new Router()

router.get('/getTest', async ctx => {
  // 后端允许cors跨域请求
  await cors()
  ctx.body = JSON.parse(fs.readFileSync('./static/test.json'))
})

// 将koa和两个中间件连起来
app.use(router.routes()).use(router.allowedMethods())


app.listen(3000)
